//
//  ParticipationModel.m
//  Participation
//
//  Created by mac 王少宁 15/3/18.
//  Copyright (c) 2015年 BLUEBLACK. All rights reserved.
//  参与

#import "ParticipationModel.h"
#import "ParticipationTabelViewCell.h"



@implementation SNPartLinkDataModel

- (instancetype)initWithDict:(NSDictionary *)dict
{
    if ([super init]) {
        
    }
    return self;
}

+ (instancetype)modelWithDict:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

@end





@implementation ParticipationModel

-(instancetype)initWithDict:(NSDictionary *)dict
{
    if (self = [super init]) {
        _ID = [dict[@"id"] stringValue];
        _cmid = dict[@"cmid"];
        _mtype = [dict[@"mtype"] stringValue];
        _dateline = [dict[@"dateline"] stringValue];
        _title = dict[@"title"];
        _pic = dict[@"pic"];
        _content = dict[@"content"];
        _width = [dict[@"width"] stringValue];
        _height = [dict[@"height"] stringValue];
        _page = [dict[@"page"] stringValue];
        _name = @"";
        NSString * name = dict[@"name"];
        if (name && name.length) {
            _name = name;
        }
        
        NSDictionary * linkdata = dict[@"linkdata"];
        if ([_mtype isEqualToString:@"1"]) {
            _linkDataModel = [SNPartLinkDataSystemNotifyModel modelWithDict:linkdata];
        } else if ([_mtype isEqualToString:@"2"]) {
            _linkDataModel = [SNPartLinkDataWebModel modelWithDict:linkdata];
        } else if ([_mtype isEqualToString:@"3"]) {
            _linkDataModel = [SNPartLinkDataListModel modelWithDict:linkdata];
        } else if ([_mtype isEqualToString:@"4"]) {
            _linkDataModel = [SNPartLinkDataDetailModel modelWithDict:linkdata];
        }
        
        _contentH = [XCommon heightForString:_content fontSize:13 andWidth:SCREEN_WIDTH - UF(88)] + 5;
        if (_contentH > 50) {
            _contentH = 50;
        }
        
        _cellHeight = 10 + UF(kHeightOfNormalSpace*3) + kHeightOfNormalLable*2 + 10 + [XCommon heightForString:_title fontSize:15 andWidth:SCREEN_WIDTH - UF(88)] + 1 + 5 + 20 + 5 + (SCREEN_WIDTH-UF(88))*0.5 + 15 + _contentH + 1 + 15 + 1 + 10 + 20 + 10;
    }
    return self;
}

+(instancetype)modelWithDict:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

@end






@implementation SNPartLinkDataWebModel

- (instancetype)initWithDict:(NSDictionary *)dict
{
    if ([super init]) {
        _url = dict[@"url"];
    }
    return self;
}

+ (instancetype)modelWithDict:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

@end




@implementation SNPartLinkDataDetailModel

- (instancetype)initWithDict:(NSDictionary *)dict
{
    if ([super init]) {
        _shop_id = [dict[@"shop_id"] stringValue];
        _product_id = [dict[@"product_id"] stringValue];
    }
    return self;
}

+ (instancetype)modelWithDict:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

@end




@implementation SNPartLinkDataListModel

- (instancetype)initWithDict:(NSDictionary *)dict
{
    if ([super init]) {
        _actid = [dict[@"actid"] stringValue];
    }
    return self;
}

+ (instancetype)modelWithDict:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

@end



@implementation SNPartLinkDataSystemNotifyModel

- (instancetype)initWithDict:(NSDictionary *)dict
{
    if ([super init]) {
        
    }
    return self;
}

+ (instancetype)modelWithDict:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

@end


